package scuba.DiveBuddy.Fragments.LogViewer;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import org.joda.time.DateTime;
import scuba.DiveBuddy.Class.LogEntries;
import scuba.DiveBuddy.Class.LogEntry;
import scuba.DiveBuddy.R;

import java.util.Calendar;

/**
 * @author Alex Anderson
 * @version 1.0
 * @since {4/03/14}
 */
public class LogProfileFragment extends Fragment   {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_viewer_profile, container, false);

        LogEntry current = LogEntries.getCurrent();
        Calendar c = Calendar.getInstance();

        //Setup the UI
        TimePicker p = (TimePicker)v.findViewById(R.id.timeInSelect);
        p.setIs24HourView(true);
        p.setEnabled(false);
        c.setTime(current.getTimeIn().toDateTimeToday().toDate());
        p.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
        p.setCurrentMinute(c.get(Calendar.MINUTE));

        p = (TimePicker)v.findViewById(R.id.timeOutSelect);
        p.setIs24HourView(true);
        p.setEnabled(false);
        c.setTime(current.getTimeOut().toDateTimeToday().toDate());
        p.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
        p.setCurrentMinute(c.get(Calendar.MINUTE));


        TextView t = (TextView)v.findViewById(R.id.depthSelect);
        t.setText(current.getMaxDepth() + "");

        t = (TextView)v.findViewById(R.id.startAirSelect);
        t.setText(current.getStartAir() + "");

        t = (TextView)v.findViewById(R.id.endAirSelect);
        t.setText(current.getEndAir() + "");

        t = (TextView)v.findViewById(R.id.spinDepthUnits);
        t.setText(current.getDepthUnits().toString());

        t = (TextView)v.findViewById(R.id.spinDiveType);
        t.setText(current.getDiveType().toString());

        t = (TextView)v.findViewById(R.id.spinAirUnits);
        t.setText(current.getAirUnits().toString());

        t = (TextView)v.findViewById(R.id.spinAirMixes);
        t.setText(current.getAirMix().getName());

        return v;
    }
}
